home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_01_07 / 1n07064a < prev    next >
Text File  |  1990-09-10  |  7KB  |  263 lines

  1.         page    55, 132
  2.  
  3. ;
  4. ;  Firgure 2 - Mouse support functions
  5. ;
  6. ;  Requires MASM 5.1 or later
  7. ;
  8.  
  9. %       .MODEL  memodel,lang            ;Add model and language support via
  10.                                         ;command line macros,
  11.                                         ;e.g. MASM /Dmemodel=LARGE /Dlang=C
  12.  
  13.         .CODE
  14. ;
  15. ;  Initialize the mouse driver
  16. ;
  17. ;  Arguments: none
  18. ;  Returns:   number of buttons (2 or 3)
  19. ;             Errors: -1 = Driver not installed
  20. ;                      0 = Failure to initialize
  21. ;
  22. MSstart PROC    USES BX ES
  23.         mov     ax,3533h                ;Is Int 33h valid?
  24.         int     21h
  25.         mov     ax,es
  26.         or      ax,bx
  27.         jnz     valid                   ;Not 0:0, continue
  28.         mov     ax,-1                   ;Invalid vector, abort
  29. invalid:
  30.         ret
  31. valid:
  32.         xor     ax,ax                   ;Try to initialize mouse driver
  33.         int     33h
  34.         or      ax,ax                   ;Successful?
  35.         jz      invalid                 ;Nope, abort
  36.         mov     ax,bx                   ;Yes, return # of buttons in AX
  37.         ret
  38. MSstart ENDP
  39.  
  40. ;
  41. ;  Turn on the cursor
  42. ;
  43. ;  Arguments: none
  44. ;  Returns:   none
  45. ;
  46. MSc_on  PROC
  47.         mov     ax,0001h
  48.         int     33h
  49.         ret
  50. MSc_on  ENDP
  51.  
  52. ;
  53. ;  Turn off the cursor
  54. ;
  55. ;  Arguments: none
  56. ;  Returns:   none
  57. ;
  58. MSc_off PROC
  59.         mov     ax,0002h
  60.         int     33h
  61.         ret
  62. MSc_off ENDP
  63.  
  64. ;
  65. ;  Get mouse position
  66. ;
  67. ;  Arguments: X position (by reference)
  68. ;             Y position (by reference)
  69. ;             Button status (by reference)
  70. ;  Returns:   none
  71. ;
  72.     IF @DataSize
  73. MSgetxy PROC    USES BX CX DX ES, ms_x:PTR, ms_y:PTR, buttons:PTR
  74.     ELSE
  75. MSgetxy PROC    USES BX CX DX, ms_x:PTR, ms_y:PTR, buttons:PTR
  76.     ENDIF
  77.         mov     ax,0003h
  78.         int     33h
  79.     IF @DataSize                                ;(Far arguments)
  80.         mov     ax,bx                           ;Store button status
  81.         les     bx,buttons
  82.         mov     es:[bx],ax
  83.         les     bx,ms_x                         ;Store X
  84.         mov     es:[bx],cx
  85.         les     bx,ms_y                         ;Store Y
  86.         mov     es:[bx],dx
  87.     ELSE                                        ;(Near arguments)
  88.         mov     ax,bx                           ;Store button status
  89.         mov     bx,buttons
  90.         mov     [bx],ax
  91.         mov     bx,ms_x                         ;Store X
  92.         mov     [bx],cx
  93.         mov     bx,ms_y                         ;Store Y
  94.         mov     [bx],dx
  95.     ENDIF
  96.         ret
  97. MSgetxy ENDP
  98.  
  99. ;
  100. ;  Set mouse position
  101. ;
  102. ;  Arguments: X position
  103. ;             Y position
  104. ;  Returns:   none
  105. ;
  106. MSsetxy PROC    USES CX DX, ms_x:WORD, ms_y:WORD
  107.         mov     ax,0004h
  108.         mov     cx,ms_x
  109.         mov     dx,ms_y
  110.         int     33h
  111.         ret
  112. MSsetxy ENDP
  113.  
  114. ;
  115. ;  Set mouse horizontal limits
  116. ;
  117. ;  Arguments: Minimum X bound
  118. ;             Maximum X bound
  119. ;  Returns:   none
  120. ;
  121. MSxlim  PROC    USES CX DX, min_x:WORD, max_x:WORD
  122.         mov     ax,0007h
  123.         mov     cx,min_x
  124.         mov     dx,max_x
  125.         int     33h
  126.         ret
  127. MSxlim  ENDP
  128.  
  129. ;
  130. ;  Set mouse vertical limits
  131. ;
  132. ;  Arguments: Minimum Y bound
  133. ;             Maximum Y bound
  134. ;  Returns:   none
  135. ;
  136. MSylim  PROC    USES CX DX, min_y:WORD, max_y:WORD
  137.         mov     ax,0008h
  138.         mov     cx,min_y
  139.         mov     dx,max_y
  140.         int     33h
  141.         ret
  142. MSylim  ENDP
  143.  
  144. ;
  145. ;  Set mouse graphics cursor shape
  146. ;
  147. ;  Arguments: Horizontal (X) position
  148. ;             Vertical (Y) position
  149. ;             Pointer to screen & cursor masks
  150. ;  Returns:   none
  151. ;
  152. MSsetcg PROC    Uses BX CX DX ES, pos_x:WORD, pos_y:WORD, masks:FAR PTR
  153.         mov     ax,0009h
  154.         mov     bx,pos_x
  155.         mov     cx,pos_y
  156.         les     dx,masks
  157.         int     33h
  158.         ret
  159. MSsetcg ENDP
  160.  
  161. ;
  162. ;  Set mouse text cursor type
  163. ;
  164. ;  Arguments: 0=Attribute cursor, 1=Hardware cursor
  165. ;             Screen mask for attribute cursor/Starting hardware scan line
  166. ;             Cursor mask for attribute cursor/Ending hardware scan line
  167. ;  Returns:   none
  168. ;
  169. MSsetct PROC    USES BX CX DX, ctype:WORD, smask:WORD, cmask:WORD
  170.         mov     ax,000Ah
  171.         mov     bx,ctype
  172.         mov     cx,smask
  173.         mov     dx,cmask
  174.         int     33h
  175.         ret
  176. MSsetct ENDP
  177.  
  178. ;
  179. ;  Set sensitivity
  180. ;
  181. ;  Arguments: Mickeys to cause 8 pixel horizontal change
  182. ;             Mickeys to cause 8 pixel vertical change
  183. ;             Double speed threshold
  184. ;  Returns:   none
  185. ;
  186. MSssens PROC    USES BX CX DX, sens_x:WORD, sens_y:WORD, doubl:WORD
  187.         mov     ax,001Ah
  188.         mov     bx,sens_x
  189.         mov     cx,sens_y
  190.         mov     dx,doubl
  191.         int     33h
  192.         ret
  193. MSssens ENDP
  194.  
  195. ;
  196. ;  Get sensitivity
  197. ;
  198. ;  Arguments: Mickeys to cause 8 pixel horizontal change (reference)
  199. ;             Mickeys to cause 8 pixel vertical change (reference)
  200. ;             Double speed threshold (reference)
  201. ;  Returns:   Above 3 values by reference
  202. ;
  203.     IF @DataSize
  204. MSgsens PROC    USES BX CX DX ES, sens_x:PTR, sens_y:PTR, doubl:PTR
  205.     ELSE
  206. MSgsens PROC    USES BX CX DX, sens_x:PTR, sens_y:PTR, doubl:PTR
  207.     ENDIF
  208.         mov     ax,001Bh                        ;Get data
  209.         int     33h
  210.     IF @DataSize                                ;(Far pointers)
  211.         mov     ax,bx                           ;Save X Mickeys
  212.         les     bx,sens_x                       ;Store X Mickeys
  213.         mov     es:[bx],ax
  214.         les     bx,sens_y                       ;Store Y Mickeys
  215.         mov     es:[bx],cx
  216.         les     bx,doubl                        ;Store double speed threshold
  217.         mov     es:[bx],dx
  218.     ELSE                                        ;(Near pointers)
  219.         mov     ax,bx                           ;Save X Mickeys
  220.         mov     bx,sens_x                       ;Store X Mickeys
  221.         mov     [bx],ax
  222.         mov     bx,sens_y                       ;Store Y Mickeys
  223.         mov     [bx],cx
  224.         mov     bx,doubl                        ;Store double speed threshold
  225.         mov     [bx],dx
  226.     ENDIF
  227.         ret
  228. MSgsens ENDP
  229.  
  230. ;
  231. ;  Install user-defined event handler
  232. ;
  233. ;  Arguments: New call mask
  234. ;             New vector
  235. ;             Pointer to storage for old call mask
  236. ;             Pointer to storage for old vector
  237. ;
  238. MSvinst PROC    USES BX CX DX DS ES, cmask:WORD, vect:FAR PTR, \
  239.                                      omask:PTR, ovect:PTR
  240.         mov     ax,0014h                        ;Setup int
  241.         mov     cx,cmask                        ;Pass call mask
  242.         les     dx,vect                         ;Pass new vector
  243.         int     33h
  244.     IF @DataSize                                ;(Far arguments)
  245.         lds     bx,omask                        ;Store old call mask
  246.         mov     ds:[bx],cx
  247.         lds     bx,ovect
  248.         mov     ds:[bx],dx                      ;Store old vector
  249.         mov     ax,es
  250.         mov     ds:[bx+2],ax
  251.     ELSE                                        ;(Near arguments)
  252.         mov     bx,omask                        ;Store old call mask
  253.         mov     [bx],cx
  254.         mov     bx,ovect                        ;Store old vector
  255.         mov     [bx],dx
  256.         mov     ax,es
  257.         mov     [bx+2],ax
  258.     ENDIF
  259.         ret
  260. MSvinst ENDP
  261.  
  262.         end
  263.